import { ConsultType } from '@/enums'
import type { PartialConsult } from '@/types/consult'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useConsultStore = defineStore(
  'cp-consult',
  () => {
    const consult = ref<PartialConsult>({})
    // 设置问诊类型
    const setType = (type: ConsultType) => (consult.value.type = type)
    //选择极速问诊的类型
    const setIllnessType = (type: 0 | 1) =>(consult.value.illnessType = type)
    //设置科室
    const setDep = (id:string) =>(consult.value.depId=id)
    const setIllness =(illness: Pick<PartialConsult, 'illnessDesc' | 'illnessTime' | 'consultFlag' | 'pictures'>)=>{
      consult.value.illnessDesc=illness.illnessDesc
      consult.value.consultFlag=illness.consultFlag
      consult.value.illnessTime=illness.illnessTime
      consult.value.pictures=illness.pictures
    }
    const clear = () =>{
      consult.value = {}
    }
    const setPatient = (id:string) =>(consult.value.patientId = id)
    return{
      setType,
      consult,
      setIllnessType,
      setDep,
      setIllness,
      setPatient,
      clear
    }
  },
  {
    persist:true
  }

)